<!DOCTYPE html>
<html ng-app="lesson" ng-controller="lesson11">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="http://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js"></script>
    <style>
        table,th, td
        {
            border: 1px solid black;
            vertical-align:top;
            padding:12px;
        }
    </style>
</head>
<body>
<p ng-show="IsLoading">订单加载中</p>
<div ng-show="!IsLoading">
    <div>
        <span>订单编号：</span><input type="text" ng-model="searchOrderId"/><button ng-click="searchOrder()">查询</button>
    </div>
    <table>
        <thead>
        <tr>
            <th>订单编号</th>
            <th>卖家</th>
            <th>商品详情</th>
            <th>订单总价</th>
            <th>物流状态</th>
            <th>订单状态</th>
            <th>下单日期</th>
        </tr>
        </thead>
        <!--<tbody ng-repeat="x in orderList|filter:orderFilter">-->
        <tbody ng-repeat="x in orderList">
        <tr>
            <td>{{x.orderId}}</td>
            <td>{{x.sealer}}</td>
            <td>
                <ul ng-repeat="p in x.products" style="border-bottom: 1px solid #333333;">
                    <li>{{p.name}}</li>
                    <li>{{p.description}}</li>
                    <li>{{p.price}}</li>
                    <li>{{p.oldPrice}}</li>
                    <li>{{p.amount}}</li>
                    <li>{{p.payment}}</li>
                </ul>
            </td>
            <td>{{x.orderPayment}}</td>
            <td>{{x.traffic}}</td>
            <td>{{x.status}}</td>
            <td>{{x.creatTime}}</td>
        </tr>
        </tbody>
    </table>
</div>
<script>

    var app=angular.module("lesson",[]);
    app.controller("lesson11",function ($scope) {
        var orderListBase=[
            {
                orderId:'GH2016032010001',
                creatTime:'2016-03-20 10:01',
                sealer:'专营店1卖家',
                traffic:'快递已取件',
                status:'卖家已发货',
                products:[
                    {
                        name:'黑色夹克衫',
                        description:'质量扎实',
                        price:200.00,
                        oldPrice:350.00,
                        amount:1,
                        payment:200.00
                    }
                ],
                orderPayment:200.00
            },
            {
                orderId:'GH2016032010002',
                creatTime:'2016-03-20 12:01',
                sealer:'小诗家',
                traffic:'快递已派送',
                status:'卖家已发货',
                products:[
                    {
                        name:'针织衫',
                        description:'颜色新颖',
                        price:120.00,
                        oldPrice:260.00,
                        amount:1,
                        payment:120.00
                    },
                    {
                        name:'棒球服',
                        description:'颜色新颖',
                        price:60.00,
                        oldPrice:160.00,
                        amount:1,
                        payment:60.00
                    },
                ],
                orderPayment:180.00
            },
            {
                orderId:'GH2016032010003',
                creatTime:'2016-03-19 16:01',
                sealer:'胜利家装店',
                traffic:'已派送成功，用户已签收',
                status:'买家已确认收货',
                products:[
                    {
                        name:'吸盘把手',
                        description:'白色耐久使用',
                        price:38.00,
                        oldPrice:80.00,
                        amount:2,
                        payment:76.00
                    }
                ],
                orderPayment:76.00
            }
        ];

        $scope.orderList=[];
        $scope.IsLoading=false;
        $scope.LoadOrderList=function (accountId,pageSize,pageIndex) {
            $scope.IsLoading=true;
            $scope.orderList=orderListBase;
            $scope.IsLoading=false;
        };
//        $scope.orderFilter=function(order){
//            if($scope.searchOrderId!=''){
//                return order.orderId.indexOf($scope.searchOrderId)>=0;
//            }
//        };

        //改成这样
        $scope.searchOrder=function() {
            var searchOrderList = [];
            if($scope.searchOrderId!='') {
                for (var order in orderListBase) {
                    if (orderListBase[order].orderId.indexOf($scope.searchOrderId) >= 0) {
                        searchOrderList.push(orderListBase[order]);
                    }
                }
            }
            //console.log(searchOrderList);
            $scope.orderList= searchOrderList;

        };
        $scope.LoadOrderList();
    });
</script>

<script>
    for(var arr=[],i=0;i<5;arr[i++]=i){}
    console.log(arr);
</script>

</body>
</html>